<%@ include file="/common/taglibs.jsp"%>

<head>
<title><fmt:message key="copyrightRegisterationList.title" /></title>
<meta name="menu" content="CopyrightRegisterationMenu" />

<script type="text/javascript"
	src="<c:url value='/scripts/lib/plugins/jquery.zclip.min.js'/>"></script>
</head>
</head>

<div class="span9">
	<h2>
		<fmt:message key="copyrightRegisterationList.heading" />
	</h2>
	<security:authorize ifAllGranted="ROLE_ADMIN">
		<form method="post" action="${ctx}/copyrightRegisterations"
			id="searchForm" class="form-search">
			<div id="search" class="input-append">
				<input type="text" size="20" name="q" id="query"
					value="<s:property value="query"/>"
					placeholder="<fmt:message key="search.enterTerms"/>"
					class="input-medium search-query" />
				<button id="button.search" class="btn" type="submit">
					<i class="icon-search"></i>
					<fmt:message key="button.search" />
				</button>
			</div>
		</form>
	</security:authorize>

	<%-- <fmt:message key="copyrightRegisterationList.message" /> --%>

	<div id="actions" class="form-actions">
		<a class="btn btn-primary"
			href="<c:url value='/syncCopyrightRegisteration'/>"> <i
			class="icon-refresh icon-white"></i> <fmt:message key="button.sync" />
		</a>

		<button class="btn btn-primary" id="btn_rowSelectedCopyer">
			<i class="icon-pencil icon-white"></i>
			<fmt:message key="button.copy" />
		</button>
	</div>

	<display:table name="copyrightRegisterations"
		class="table table-condensed table-striped table-hover" requestURI=""
		id="copyrightRegisterationList" export="true" pagesize="25">
		<display:column title="<input type='checkbox' id='check_all'">
			<input type="checkbox" name="chk_list"
				value="${copyrightRegisterationList.id}\t${copyrightRegisterationList.serialNum}\t${copyrightRegisterationList.contact}\t${copyrightRegisterationList.copyrighter}\t${copyrightRegisterationList.email}\t${copyrightRegisterationList.mobileNum}\t${copyrightRegisterationList.phoneNum}\t${copyrightRegisterationList.productName}\t${copyrightRegisterationList.registDate}\n" />
		</display:column>

		<display:column property="id" sortable="true" class="notCopy"
			href="editCopyrightRegisteration" media="html" paramId="id"
			paramProperty="id" titleKey="copyrightRegisteration.id" />

		<display:column property="serialNum" sortable="true" 
			titleKey="copyrightRegisteration.serialNum" />
		<display:column property="copyrighter" sortable="true"
			titleKey="copyrightRegisteration.copyrighter" />
		<display:column property="productName" sortable="true"
			titleKey="copyrightRegisteration.productName" />
		<display:column property="contact" sortable="true"
			titleKey="copyrightRegisteration.contact" />
		<display:column property="phoneNum" sortable="true"
			titleKey="copyrightRegisteration.phoneNum" />
		<display:column property="mobileNum" sortable="true"
			titleKey="copyrightRegisteration.mobileNum" />
		
		<display:column property="email" sortable="true"
			titleKey="copyrightRegisteration.email" />
		
		<display:column property="registDate" sortable="true" class="notCopy"
			titleKey="copyrightRegisteration.registDate" />

		<display:setProperty name="paging.banner.item_name" value="">
			<%-- <fmt:message key="copyrightRegisterationList.copyrightRegisteration" /> --%>
		</display:setProperty>
		<display:setProperty name="paging.banner.items_name" value="">
			<%-- <fmt:message key="copyrightRegisterationList.copyrightRegisterations" /> --%>
		</display:setProperty>

		<display:setProperty name="export.excel.filename">
			<fmt:message key="copyrightRegisterationList.title" />.xls</display:setProperty>
		<display:setProperty name="export.csv.filename">
			<fmt:message key="copyrightRegisterationList.title" />.csv</display:setProperty>
		<display:setProperty name="export.pdf.filename">
			<fmt:message key="copyrightRegisterationList.title" />.pdf</display:setProperty>
	</display:table>
</div>

<script type="text/javascript">
	$(document).ready(function() {
		
			$("#copyrightRegisterationList").children('thead').find('th').css({"background-color":"#d9edf7","text-align":"center","white-space":"nowrap"});
			$("#copyrightRegisterationList").children('tbody').find('td').css({"text-align":"center","white-space":"nowrap"});
			//$("#copyrightRegisterationList").children('tr').find('td')
			//check if data is not empty
			if($(":checkbox[name='chk_list']").length > 0){
				$("#check_all").bind("click",function() {
					if($(this).attr("checked") == "checked"){
						$(":checkbox[name='chk_list']").attr("checked",true);
					}else{
						$(":checkbox[name='chk_list']").removeAttr("checked");
					}
				});

				$("#btn_rowSelectedCopyer").zclip({
					path : "<c:url value='/scripts/lib/plugins/ZeroClipboard.swf'/>",
					copy : function() {
						if ($(":checkbox[name='chk_list']:checked").size() > 0) {
							var result = "";
							$(":checkbox[name='chk_list']:checked").each(function() {
									var flag = false;
									$(this).parent().siblings().each(function(){
										if(!($(this).hasClass("notCopy"))){
											result += $(this).text() + "\t";
											flag = true;
										}
									});
									
									if(flag)
										result += "\n";
							}); 
							return result;
						} else {
							alert('<fmt:message key="alert.atLeastOneRowSelect" />');
						}
					}
				});
				
			}else{
				$("#btn_rowSelectedCopyer").attr("disabled",true);
			}
			

	});
</script>

